import request from '@/service'

// 发布帖子
export function publishPost(postInfo: any) {
  return request.post({
    url: '/posts',
    data: {
      ...postInfo
    }
  })
}
// 删除帖子
export function removePost(post_id: number) {
  return request.delete({
    url: `/posts/${post_id}`
  })
}

// 修改帖子
export function updatePost(post_id: number, postInfo: any) {
  return request.post({
    url: `/posts/${post_id}`,
    data: {
      ...postInfo
    }
  })
}

// 修改帖子状态
export function updatePostStatus(post_id: number, status: string) {
  return request.post({
    url: `/posts/${post_id}/status`,
    params: {
      status
    }
  })
}

// 获取和模糊查询全部帖子帖子
export function getPosts(queryInfo?: any) {
  return request.get({
    url: `/posts`,
    params: {
      ...queryInfo
    }
  })
}

// 获取帖子评论
export function getComments(post_id: number) {
  return request.get({
    url: `/comment/${post_id}`
  })
}

// 删除评论
export function removeComment(comment_id: number) {
  return request.delete({
    url: `/comment/${comment_id}`
  })
}
